package com.johnson.news.activity;

import androidx.appcompat.app.AppCompatActivity;
import io.reactivex.functions.Consumer;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;

import com.johnson.news.R;
import com.johnson.news.databinding.ActivityAskMeComplaintNoticeBinding;
import com.johnson.news.model.bean.AskMeNotice;
import com.johnson.news.model.remote.RemoteDataSource;
import com.youmbe.library.BaseBindingActivity;

public class AskMeComplaintNoticeActivity extends BaseBindingActivity<ActivityAskMeComplaintNoticeBinding> {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    protected void init() {
        dataBinding.noticeContent.setVerticalScrollBarEnabled(false);
        dataBinding.noticeContent.setHorizontalScrollBarEnabled(false);
        dataBinding.noticeContent.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        dataBinding.noticeContent.getSettings().setJavaScriptEnabled(true);
        dataBinding.noticeContent.getSettings().setSupportZoom(false);
        dataBinding.noticeContent.getSettings().setBuiltInZoomControls(false);
        dataBinding.noticeContent.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        dataBinding.noticeContent.getSettings().setTextZoom(88);

        getData();
    }

    void getData() {
        RemoteDataSource.getRemoteDataSource()
                .getComplaintNotice(this, 0)
                .subscribe(new Consumer<AskMeNotice>() {
                    @Override
                    public void accept(AskMeNotice askMeNotice) throws Exception {
                        dataBinding.noticeContent.loadDataWithBaseURL(null, askMeNotice.content, "text/html", "utf-8", null);
                    }
                });
    }

    @Override
    public int getContentViewId() {
        return R.layout.activity_ask_me_complaint_notice;
    }
}
